package com.lib.utils;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;


import com.mzbopen.libhorseracelamp.ClickCallBack;
import com.mzbopen.libhorseracelamp.ContainerEntity;
import com.mzbopen.libhorseracelamp.ScrollTopNewsContainerView;

import java.util.ArrayList;
import java.util.List;

public class HorseRaceLampActivity extends AppCompatActivity {
    ScrollTopNewsContainerView test_scv;
    Button start;
    Button stop;
    Button restart;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_horse_race_lamp);
        test_scv = findViewById(R.id.test_scv);
        start = findViewById(R.id.start);
        stop = findViewById(R.id.stop);
        restart = findViewById(R.id.restart);
        List<ContainerEntity> data = new ArrayList<>();
        ContainerEntity entity1 = new ContainerEntity();
        entity1.setData("我是第一个轮转跑马灯啊啊哈哈哈哈11111111");
        data.add(entity1);
        ContainerEntity entity2 = new ContainerEntity();
        entity2.setData("我是第二个轮转跑马灯啊啊哈哈哈哈22222222");
        data.add(entity2);

        ContainerEntity entity3 = new ContainerEntity();
        entity3.setData("我是第三个轮转跑马灯啊啊哈哈哈哈33333333");
        data.add(entity3);
        test_scv.setData(data);
        test_scv.startMove();
        test_scv.setCallBack(new ClickCallBack() {
            @Override
            public void onClick(View view, int position) {
                Toast.makeText(view.getContext(),"position_data=" + data.get(position).getData(),Toast.LENGTH_LONG).show();

            }
        });
        start.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                test_scv.start();

            }
        });
        stop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                test_scv.stop();

            }
        });
        restart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                test_scv.restart();

            }
        });

    }
}
